package com.gbiac.jeecgRPT;

import org.eclipse.birt.report.engine.api.script.IReportContext;
import org.eclipse.birt.report.engine.api.script.ScriptException;
import org.eclipse.birt.report.engine.api.script.element.IReportDesign;
import org.eclipse.birt.report.engine.api.script.eventadapter.ReportEventAdapter;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.TableHandle;

public class DynamicTableColumnHandle extends ReportEventAdapter {
	private static String dynamicColumns; //表头数

	//private static PrintWriter pw;
	
	@Override
	public void initialize(IReportContext reportContext) {
		// TODO Auto-generated method stub
		try{
			super.initialize(reportContext);
			dynamicColumns = (String)reportContext.getParameterValue("colNum");

		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void beforeFactory(IReportDesign report, IReportContext reportContext) {
		// TODO Auto-generated method stub
		try {
			super.beforeFactory(report, reportContext);
		} catch (ScriptException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		try{
			TableHandle mytable30 = (TableHandle) reportContext.getDesignHandle().findElement("table30");
			TableHandle mytable32 = (TableHandle) reportContext.getDesignHandle().findElement("table32");
			TableHandle mytable34 = (TableHandle) reportContext.getDesignHandle().findElement("table34");
			TableHandle mytable36 = (TableHandle) reportContext.getDesignHandle().findElement("table36");
			TableHandle mytable38 = (TableHandle) reportContext.getDesignHandle().findElement("table38");
			if(dynamicColumns.equals("30"))
			{
				mytable32.drop();
				mytable34.drop();
				mytable36.drop();
				mytable38.drop();
				
			}else if(dynamicColumns.equals("32"))
			{
				mytable30.drop();
				mytable34.drop();
				mytable36.drop();
				mytable38.drop();	
			}else if(dynamicColumns.equals("34"))
			{
				mytable30.drop();
				mytable32.drop();
				mytable36.drop();
				mytable38.drop();	
			}else if(dynamicColumns.equals("36"))
			{
				mytable30.drop();
				mytable32.drop();
				mytable34.drop();
				mytable38.drop();
			}else if(dynamicColumns.equals("38"))
			{
				mytable30.drop();
				mytable32.drop();
				mytable34.drop();
				mytable36.drop();
			}else
			{
				mytable30.drop();
				mytable32.drop();
				mytable34.drop();
				mytable36.drop();
				mytable38.drop();	
				
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
	}

}
